﻿using AutoMapper;
using Equipment.API;
using Equipment.API.DTOs.RequestDto.OutgoinginspectionRequest;
using Equipment.API.Application.Service.OutgoinginspectionService;
using Equipment.Errorcode;
using Equipment.Infrastructure.Interfaces;
using Equipment.Infrastructure.Repositories;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Equipment.API.DTOs.ResponseDto.OutgoinginspectionRequest;
using Equipment.Domain.Outgoinginspectionfolder;


namespace Equipment.API.Controllers
{
    /// <summary>
    /// 质检管理控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class OutgoinginspectionController : ControllerBase
    {
        private readonly InspectorsService _inspectorsService;

        private readonly InspectiondepartmentService _inspectiondepartmentService;

        private readonly OutgoinginspectionServices _outgoinginspectionServices;

        private readonly IMapper _mapper;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="inspectorsService"></param>
        /// <param name="inspectiondepartmentService"></param>
        /// <param name="outgoinginspectionServices"></param>
        /// <param name="mapper"></param>
        public OutgoinginspectionController(InspectorsService inspectorsService, InspectiondepartmentService inspectiondepartmentService, OutgoinginspectionServices outgoinginspectionServices, IMapper mapper)
        {
            _inspectorsService = inspectorsService;
            _inspectiondepartmentService = inspectiondepartmentService;
            _outgoinginspectionServices = outgoinginspectionServices;
            _mapper = mapper;
        }

        /// <summary>
        /// 新增出货检验信息
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult> AddOutgoinginspection(AddOutgoinginspectionResponseDto param)
        {
            return await _outgoinginspectionServices.AddOutgoinginspection(param);
        }

        /// <summary>
        /// 质检管理信息查询
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult> GetOutgoinginspection([FromQuery]GetOutgoingRequestDto param, int pageNumber = 1, int pageSize = 2)
        {
            return await _outgoinginspectionServices.GetOutgoinginspection(param, pageNumber, pageSize);
        }

        /// <summary>
        /// 修改出货检验信息
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult> UpdateOutgoinginspection(UpdateOutgoinginsRequestDto param)
        {
            return await _outgoinginspectionServices.UpdateOutgoinginspection(param);
        }
        /// <summary>
        /// 删除出货检验信息
        /// </summary>
        /// <param name="Outgoinginspectionid"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<ApiResult> DeleteOutgoinginspection(int Outgoinginspectionid)
        {
            return await _outgoinginspectionServices.DeleteOutgoinginspection(Outgoinginspectionid);
        }


        /// <summary>
        /// 检验人信息显示
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult> GetInspectorsList()
        {
            return await _inspectorsService.GetInspectorsList();
        }

        /// <summary>
        /// 获取检验部门列表信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult> GetInspectiondepartmentList()
        {
            return await _inspectiondepartmentService.GetInspectiondepartmentList();
        }



    }
}